package com.baboba.rummy.web.client.arena;

import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;

public class ArenaView extends Composite {
	private DockLayoutPanel panel;
	private DecoratorPanel absolutePanelWrapper;
	private AbsolutePanel absolutePanel;

	public ArenaView(){
		/*final FlexTable topPanel = new FlexTable();
		//topPanel.setWidth("100%");
		//topPanel.setBorderWidth(1);
		
		for (int i = 0; i < 15; i++)
			for (int l = 0; l < 8; l++) {
				final Label widget = new Label();
				widget.setWidth("25px");
				widget.setHeight("20px");
				final int x = i;
				final int y = l;
				//widget.getElement().setDraggable(Element.DRAGGABLE_TRUE);
				widget.addDragOverHandler(new DragOverHandler() {
					@Override
					public void onDragOver(DragOverEvent event) {
						//dropLabel.setText("Dragging Over");
					}
				});
				widget.addDragLeaveHandler(new DragLeaveHandler() {
					@Override
					public void onDragLeave(DragLeaveEvent event) {
						//event.
					}
				});
				widget.addDropHandler(new DropHandler() {
					@Override
					public void onDrop(DropEvent event) {
						CardView cardView = (CardView)DragDropContext.getDragSourceWiget();
						topPanel.setWidget(x, y, cardView);
					}
				});
				topPanel.setWidget(i, l, widget);
			}
		
		this.initWidget(topPanel);*/
		
		panel = new DockLayoutPanel(Unit.PX);
		panel.getElement().getStyle().setBorderWidth(2, Unit.PX);
		panel.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
		panel.getElement().getStyle().setBorderColor("red");
		
		absolutePanel = new AbsolutePanel();
		//absolutePanel.setSize("200px", "300px");
		
		
		absolutePanel.getElement().getStyle().setBorderWidth(1, Unit.PX);
		absolutePanel.getElement().getStyle().setBorderStyle(BorderStyle.SOLID);
		absolutePanel.getElement().getStyle().setBorderColor("black");
		
		absolutePanel.add(new Label("test"), 10, 10);
		/*absolutePanelWrapper = new DecoratorPanel();
	    absolutePanelWrapper.setWidget(absolutePanel);*/
	    
	    //panel.setWidget(0, 0, absolutePanel);
	    this.initWidget(panel);
	}
	
	public void redrawArenaPanel(){
		absolutePanel.setSize(panel.getElement().getClientWidth()+"px", panel.getElement().getClientHeight()+"px");
		panel.add(absolutePanel);
	}
}
